﻿using DataWorks_Sqlite.MappingClass;
using DataWorks_Tools.BasicMethods;
using DataWorks_Tools.DBC.DBCProcess;
using DataWorks_Tools.MappModals;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataWorks_Tools.ProcessExcute.DBCMessageTransfer
{
    public static class DBCMessageTransferProcess
    {
        public static async Task<List<string>> DBCMessageTransferProcessExcute(Dictionary<(uint,uint), DbcParserLib.Model.Message[]> mes, dw_props_admin dw_Props_Admin, dw_props_dbcmessage row)
        {
            var selectdatefilearray = row.selecteddirectory.ReComma().Split(',');
            var originaldatapath = row.originaldatapath.YXHPathReplace();
            var savedatapath = row.savedatapath.YXHPathReplace();
            var dbcpath = row.dbcpath.YXHPathReplace();
            var ismultithreads = dw_Props_Admin.ismultithreads;
            DBCMessageTransferModal modal = new DBCMessageTransferModal();
            modal.odpath = originaldatapath;
            modal.rdpath = savedatapath;
            modal.dbcpath = dbcpath;
            modal.datedir = selectdatefilearray;
            if (originaldatapath != null && savedatapath != null && selectdatefilearray != null && dbcpath != null)
            {
                if (ismultithreads == 1)
                {
                    var t = await DBCMessageTransferUnify.DBCMessageTransferProcessMultithreadedExecute(mes,modal);
                    return t;
                }
                else
                {
                    var t = await DBCMessageTransferUnify.DBCMessageTransferProcessExcute(mes, modal);
                    return t;
                }
            }
            else
            {
                return new List<string>() { "参数错误" };
            }

        }
    }
}
